public static void Factorial(int n)
{
var number = new int[999999];
number[0] = 1;
int numLength = 1;
for (int times = 2; times <= n; times++)
numLength = Multiply(times, number,numLength);
for (int i = numLength - 1; i >= 0; i--)
Console.Write(number[i]);
}
static int Multiply(int times, int[] number,int numLength)
{
int carry = 0;
for (int i = 0; i < numLength; i++)
{
int product = number[i] * times + carry;
number[i] = product % 10;
carry = product / 10;
}
while (carry != 0)
{
number[numLength] = carry % 10;
carry /= 10;
numLength++;
}
return numLength;
}